/**
 业主详情页面
 **/
(function (vc) {
    vc.extends({
        data: {
            shopIntegralInfo: {
                integralId: "",
                integralName: '',
                amount: "",
                shopName: "",
                shopId: "",
                _currentTab: 'shopIntegralDetail',
            }
        },
        _initMethod: function () {

            $that._loadShopIntegralInfo();
          
        },
        _initEvent: function () {
            vc.on('shopIntegral', 'listShopIntegralData', function (_info) {
                $that._loadShopIntegralInfo();
                $that.changeTab($that.shopIntegralInfo._currentTab);
            });
            vc.on('shopIntegral', 'listShopIntegralWithdrawal',function(){
                $that.shopIntegralInfo._currentTab = 'applyWithholdShopIntegral';
                $that.changeTab($that.shopIntegralInfo._currentTab);
            })
        },
        methods: {
            _loadShopIntegralInfo: function () {
                let param = {
                    params: {
                        page: 1,
                        row: 1,
                        shopId: vc.getCurrentCommunity().shopId,
                    }
                }
                //发送get请求
                vc.http.apiGet('/integral.queryShopIntegral',
                    param,
                    function (json, res) {
                        let _json = JSON.parse(json);
                        vc.copyObject(_json.data[0], $that.shopIntegralInfo);
                        $that.changeTab($that.shopIntegralInfo._currentTab);
                    },
                    function (errInfo, error) {
                        console.log('请求失败处理');
                    }
                );
            },
            changeTab: function (_tab) {
                $that.shopIntegralInfo._currentTab = _tab;
                vc.emit(_tab, 'switch', {
                    integralId: $that.shopIntegralInfo.integralId,
                    integralName: $that.shopIntegralInfo.integralName,
                });
            },
            _openApplyWithholdShopIntegral:function(){
                vc.emit('withholdIntegral', 'openWithholdIntegralModal',{
                    integralId:$that.shopIntegralInfo.integralId,
                    amount:$that.shopIntegralInfo.amount,
                    shopId:$that.shopIntegralInfo.shopId,
                })
            }
        }
    });
})(window.vc);